#!/bin/bash

#判断是否为空值
if [ -n "$1" ] ; then
  data_date=$1
else
  data_date=`date -d '-1 days' +%F`
fi

#加载数据到表中
ADS_LOG_LOAD_ODS_SQL="
LOAD DATA INPATH '/warehouse/ads_log/${data_date}'
    OVERWRITE INTO TABLE jtp_ads_warehouse.ods_ads_log_inc PARTITION (dt='${data_date}');
"
#广告信息表
ODS_ADS_INFO_FULL_SQL="
LOAD DATA INPATH '/warehouse/ads_basic/ads/${data_date}' OVERWRITE INTO TABLE
    jtp_ads_warehouse.ods_ads_info_full PARTITION (dt='${data_date}');
"

#广告平台映射表表
ODS_ADS_PLATFORM_FULL_SQL="
LOAD DATA INPATH '/warehouse/ads_basic/ads_platform/${data_date}'
    OVERWRITE INTO TABLE jtp_ads_warehouse.ods_ads_platform_full PARTITION (dt='${data_date}');
"

#广告平台信息表
ODS_PLATFORM_INFO_FULL_SQL="
LOAD DATA INPATH '/warehouse/ads_basic/platform_info/${data_date}'
    OVERWRITE INTO TABLE jtp_ads_warehouse.ods_platform_info_full PARTITION (dt='${data_date}');
"

#产品信息表
ODS_ADS_PRODUCT_FULL_SQL="
LOAD DATA INPATH '/warehouse/ads_basic/product/${data_date}'
    OVERWRITE INTO TABLE jtp_ads_warehouse.ods_ads_product_full PARTITION (dt='${data_date}');
"

/opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -e "${ADS_LOG_LOAD_ODS_SQL}${ODS_ADS_INFO_FULL_SQL}${ODS_PLATFORM_INFO_FULL_SQL}${ODS_PLATFORM_INFO_FULL_SQL}${ODS_ADS_PRODUCT_FULL_SQL}
"






































